package com.controller;

import com.entity.Response;
import com.entity.vo.SchedulingVo;
import com.service.SchedulingService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/scheduling")
public class schedulingController {

    @Resource
    private SchedulingService schedulingService;

    @GetMapping
    public Response listScheduling() {
        return new Response().setSuccess().appendMsg("list", schedulingService.listScheduling());
    }

    @PostMapping
    public Response insertScheduling(@RequestBody SchedulingVo schedulingVo) {
        int res = schedulingService.insertScheduling(schedulingVo);
        return res > 0 ? new Response().setSuccess() : new Response().setFailed();
    }

    @GetMapping("/user")
    public Response listSchedulingByUsername(@RequestParam("username") String username) {
        return new Response().setSuccess().appendMsg("list", schedulingService.listUserScheduling(username));
    }

}
